﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

using Microsoft.Practices.Unity;

using FluentValidation;

using CloudSoft.Extensions;

using ERPStore.Extensions;

namespace ERPStore.Web.Services
{
	public class FluentValidatorService : ERPStore.Services.FluentValidatorService
	{
		public override void Configure()
		{
			base.Configure();

			DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;

			Container.RegisterType<global::FluentValidation.IValidatorFactory, ValidatorFactory>();
			var validatorFactory = Container.Resolve<global::FluentValidation.IValidatorFactory>();
			var fluentProvider = new global::FluentValidation.Mvc.FluentValidationModelValidatorProvider(validatorFactory);

			ModelValidatorProviders.Providers.Add(fluentProvider);
		}
	}
}
